﻿using Youz.Common.BLL;
using Youz.Common.Helper;
using Youz.CreditRepay.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Youz.CreditRepay.BLL
{
    public class ConfigParameters : Youz.Common.BLL.ConfigParameters
    {
        private static Sys_ConfigBLL configBLL = new Sys_ConfigBLL();

        #region Stock

        /// <summary>
        /// 停止交易
        /// </summary>
        public static bool StockStop
        {
            get { return configBLL.GetValue("StockStop", "stock", true, "0", "停止交易") == "1"; }
            set
            {
                configBLL.SetValue("StockStop", value ? "1" : "0");
            }
        }

        /// <summary>
        /// 开盘时间1
        /// </summary>
        public static string StockTradeTimes
        {
            get
            {
                return configBLL.GetValue("StockTradeTimes", "stock", true, "08:30|13:00,14:00|19:00,22:00|02:00", "交易时间");
            }
        }

        /// <summary>
        /// 默认手续费
        /// </summary>
        public static decimal StockFee
        {
            get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("StockFee", "stock", true, "0.0008", "默认手续费")); }
        }

        /// <summary>
        /// 默认最小交易数量
        /// </summary>
        public static decimal MinVolume
        {
            get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("StockMinVolume", "stock", true, "1", "默认最小交易数量")); }
        }

        /// <summary>
        /// 默认最大交易数量
        /// </summary>
        public static decimal MaxVolume
        {
            get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("StockMaxVolume", "stock", true, "100", "默认最大交易数量")); }
        }

        #endregion

        /// <summary>
        /// 消息提醒间隔时间
        /// </summary>
        public static int MessageAlertInterval
        {
            get { return TypeHelper.ConvertTo<int>(configBLL.GetValue("MessageAlertInterval", "sys", true, "30", "消息提醒间隔时间，单位为分钟")); }
        }

        /// <summary>
        /// 系统管理员手机号
        /// </summary>
        public static string AdminMobile
        {
            get { return configBLL.GetValue("AdminMobile", "sys", true, "18902840055", "系统管理员手机号"); }
        }

        public class PayEase
        {
            /// <summary>
            /// 从易支付获取余额的URL
            /// </summary>
            public static string GetBalanceUrl
            {
                get { return TypeHelper.ConvertTo<string>(configBLL.GetValue("PayEase.GetBalanceUrl", "PayEase", true, "https://pay.yizhifubj.com/merchant/virement/mer_payment_balance_check.jsp", "从易支付获取余额的URL")); }
            }

            /// <summary>
            /// 提交申请到易支付的URL
            /// </summary>
            public static string SubmitUrl
            {
                get { return TypeHelper.ConvertTo<string>(configBLL.GetValue("PayEase.SubmitUrl", "PayEase", true, "https://pay.yizhifubj.com/merchant/virement/mer_payment_submit_utf8.jsp", "提交申请到易支付的URL")); }
            }

            /// <summary>
            /// 获取易支付代付状态的URL
            /// </summary>
            public static string GetStatusUrl
            {
                get { return TypeHelper.ConvertTo<string>(configBLL.GetValue("PayEase.GetStatusUrl", "PayEase", true, "https://pay.yizhifubj.com/merchant/virement/mer_payment_status_utf8.jsp", "获取易支付代付状态的URL")); }
            }
        }

        /// <summary>
        /// 充值/支付
        /// </summary>
        public class Recharge
        {
            /// <summary>
            /// 最低充值金额(每次)
            /// </summary>
            public static decimal RechargeMinAmount
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("RechargeMinAmount", "Recharge", true, "100", "充值最低金额(每次)")); }
            }

            public static decimal RechargeFee
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("RechargeFee", "Recharge", true, "0.0085", "充值手续费(每次)")); }
            }
        }

        /// <summary>
        /// 取现
        /// </summary>
        public class GetCash
        {
            /// <summary>
            /// 最小取现金额
            /// </summary>
            public static decimal GetCashMinAmount
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("GetCashMinAmount", "GetCash", true, "100", "取现最小金额(每次)")); }
            }

            /// <summary>
            /// 最大取现金额
            /// </summary>
            public static decimal GetCashMaxAmount
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("GetCashMaxAmount", "GetCash", true, "100000", "取现最大金额(每次)")); }
            }

            /// <summary>
            /// 取现手续费
            /// </summary>
            public static decimal GetCashFee
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("GetCashFee", "GetCash", true, "1", "取现手续费(每次)")); }
            }
        }

        /// <summary>
        /// 还款
        /// </summary>
        public class Repayment
        {
            /// <summary>
            /// 手续费
            /// </summary>
            public static decimal FeeRate
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("RepaymentFeeRate", "Repayment", true, "0.0085", "还款手续费")); }
            }

            /// <summary>
            /// 金额拆分
            /// </summary>
            public static decimal AmountSplit
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("AmountSplit", "Repayment", true, "500", "还款拆分金额")); }
            }

            /// <summary>
            /// 最小账单金额
            /// </summary>
            public static decimal MaxBillAmount
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("MaxBillAmount", "Repayment", true, "1000", "还款最小账单金额")); }
            }

            /// <summary>
            /// 最小保证金率
            /// </summary>
            public static decimal CashDepositRate
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("RepaymentCashDepositRate", "Repayment", true, "0.1", "还款最小保证金率")); }
            }

            /// <summary>
            /// 最小保证金
            /// </summary>
            public static decimal MinCashDeposit
            {
                get { return TypeHelper.ConvertTo<decimal>(configBLL.GetValue("RepaymentMinCashDeposit", "Repayment", true, "100", "还款最小保证金")); }
            }

            /// <summary>
            /// 今天最后还款截止时间
            /// </summary>
            public static int TodayLastTime
            {
                get { return TypeHelper.ConvertTo<int>(configBLL.GetValue("RepaymentTodayLastTime", "Repayment", true, "16", "当天最后还款截止时间")); }
            }

            /// <summary>
            /// 每日计划开始时间
            /// </summary>
            public static int DaysBeginTime
            {
                get { return TypeHelper.ConvertTo<int>(configBLL.GetValue("RepaymentDaysBeginTime", "Repayment", true, "9", "每日计划开始时间")); }
            }

            /// <summary>
            /// 每日计划结束时间
            /// </summary>
            public static int DaysEndTime
            {
                get { return TypeHelper.ConvertTo<int>(configBLL.GetValue("RepaymentDaysEndTime", "Repayment", true, "21", "每日计划结束时间")); }
            }

            /// <summary>
            /// 每日最多还款次数
            /// </summary>
            public static int DaysCount
            {
                get { return TypeHelper.ConvertTo<int>(configBLL.GetValue("RepaymentDaysCount", "Repayment", true, "2", "每日最多还款次数")); }
            }
        }

    }
}
